package com.ccav.service.impl;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.ccav.domain.Student;
import com.ccav.mapper.StudentMapper;
import com.ccav.service.IStudentService;
import com.ccav.util.StudentPage;
import com.ccav.util.keywordUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.io.Serializable;
import java.util.List;

@Service
public class IStudentServiceImpl extends ServiceImpl<StudentMapper,Student> implements IStudentService {

    @Autowired
    private StudentMapper studentMapper;

    @Override
    public Student getById(Serializable id) {
        return studentMapper.getById(id);
    }

    @Override
    public keywordUtil findAll(StudentPage studentPage) {
        Page<Student> page = new Page<>(studentPage.getPage(), studentPage.getRow());
        List<Student> allPage = studentMapper.findAll(page,studentPage);
        if (page.getTotal()<1){
            return new keywordUtil();
        }
        return new keywordUtil(page.getTotal(), allPage);
    }
}
